package com.xcity.pomelo.request;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xcity.game.combat.Combat;
import com.xcity.pomelo.PomeloRoute;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.PomeloPacket;

@PomeloMessage(route = PomeloRoute.COMBAT_INFO)
public class CombatInfoRequest extends PomeloPacket {

	private Combat.Type type; // 战斗类型
	private JSONObject ref; // 额外数据

	// PVP
	public static final String KEY_PVP_TARGET_PLAYER_ID = "targetId";
	public static final String KEY_PVP_TARGET_BUILD_ID = "targetBuildId";
	// PVE
	public static final String KEY_PVE_STAGE_ID = "id";
	public static final String KEY_RES_STAGE_INDEX = "id";
	// ARENA
	public static final String KEY_ARENA_TARGET_ID = "id";
	// PEAK ROAD
	public static final String KEY_PEAK_ROAD_DIFFICULTY_COEFFICIENT = "diff";
	// MINE TAKE
	public static final String KEY_MINE_TAKE_MAP = "map";
	// MINE TAKE
	public static final String KEY_MINE_TAKE_POS = "pos";
	
	public static final String KEY_MINE_EIDS = "eids";

	public Combat.Type getType() {
		return type;
	}

	public void setType(Combat.Type type) {
		this.type = type;
	}

	public JSONObject getRef() {
		return ref;
	}

	public void setRef(JSONObject ref) {
		this.ref = ref;
	}
	
	//---PVP---
	public long getPVPTargetPlayerId() {
		return ref != null ? ref.getLongValue(KEY_PVP_TARGET_PLAYER_ID) : 0;
	}
	
	public int getPVPTargetBuildId() {
		return ref != null ? ref.getIntValue(KEY_PVP_TARGET_BUILD_ID) : 0;
	}
	//---PVP---
	
	//---PVE---
	public int getPVEStageId() {
		return ref != null ? ref.getIntValue(KEY_PVE_STAGE_ID) : 0;
	}
	//---PVE---
	
	//---RES---
	public int getResStageIndex(){
		return ref != null ? ref.getIntValue(KEY_RES_STAGE_INDEX) : 0;
	}
	//---RES---
	
	//---ARENA---
	public long getArenaTargetId() {
		return ref != null ? ref.getLongValue(KEY_ARENA_TARGET_ID) : 0;
	}
	//---ARENA---
	
	//---PEAK ROAD---
	/**
	 * 巅峰之路难度系数（0-简单，1-中等，2-困难）
	 * @return
	 */
	public int getPeakRoadDiffCoefficient() {
		return ref != null ? ref.getIntValue(KEY_PEAK_ROAD_DIFFICULTY_COEFFICIENT) : 0;
	}
	//---PEAK ROAD---

	//---MINE---
	public int getMap(){
		return ref != null ? ref.getIntValue(KEY_MINE_TAKE_MAP) : 0;
	}
	public int getPos(){
		return ref != null ? ref.getIntValue(KEY_MINE_TAKE_POS) : 0;
	}
	public List<Long> getEids(){
		return ref != null? ref.getJSONArray(KEY_MINE_EIDS).toJavaList(Long.class) : null;
	}
	//---MINE---
}
